package ssm.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import ssm.dao.CameraInfo;
import ssm.dao.MyResult;
import ssm.dao.Regioninfo;
import ssm.service.CameraInfoService;

import java.util.Map;

@Controller
public class CameraInfoController {

    @Autowired
    private CameraInfoService cameraInfoService;

    @RequestMapping("/getByCode")
    @ResponseBody
    public MyResult getInfoByCode(@RequestParam String code){
        if(code==null||code.equals("")){
            return MyResult.except("空值错误","传入设备编号不能为空");
        }
        CameraInfo infoByCode = cameraInfoService.getInfoByCode(code);
        return MyResult.ok(infoByCode);
    }


    @RequestMapping(value = "/getByRegion",produces = "application/json;charset=utf-8")
    @ResponseBody
    public MyResult getByCameraId(@RequestParam int id){
        Map<String,Object> cameraInfo= cameraInfoService.getByCameraId(id);
        return MyResult.ok(cameraInfo);
    }
}
